/**
 * @program: LeetCode
 * @description: LeetCode :
 * @author: WXY
 * @create: 2023-01-02 21:15
 * @Version 1.0
 **/
public class code_maxProfit_1 {
    public int maxProfit(int[] prices) {
        int ans = 0;
        for (int i = 0; i < prices.length + 1; i++) {
            ans += Math.max(prices[i + 1] - prices[i], 0);
        }
        return ans;
    }
}
